home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_008 / src / hack.mhitu.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  6KB  |  284 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  2. /* hack.mhitu.c version 1.0.1 - corrected bug for 'R' (Mike Newton)
  3.                   - also some separate code for swallowed (a3) */
  4. #include    "hack.h"
  5. extern struct monst *makemon();
  6.  
  7. /*
  8.  * mhitu: monster hits you
  9.  *      returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
  10.  */
  11. mhitu(mtmp)
  12. register struct monst *mtmp;
  13. {
  14.     register struct permonst *mdat = mtmp->data;
  15.     register int tmp, ctmp;
  16.  
  17.     nomul(0);
  18.  
  19.     /* If swallowed, can only be affected by hissers and by u.ustuck */
  20.     if(u.uswallow) {
  21.         if(mtmp != u.ustuck && mdat->mlet != 'c')
  22.             return(0);
  23.         switch(mdat->mlet) {
  24.         case 'c':
  25.             if(!rn2(13)) {
  26.                 pline("Outside, you hear %s's hissing!",
  27.                     monnam(mtmp));
  28.                 pline("%s gets turned to stone!",
  29.                     Monnam(u.ustuck));
  30.                 pline("And the same fate befalls you.");
  31.                 done_in_by(mtmp);
  32.             }
  33.             break;
  34.         case ',':
  35.             youswld(mtmp,4+u.uac,5,"The trapper");
  36.             break;
  37.         case '\'':
  38.             youswld(mtmp,rnd(6),7,"The lurker above");
  39.             break;
  40.         case 'P':
  41.             youswld(mtmp,d(2,4),12,"The purple worm");
  42.             break;
  43.         default:
  44.             pline("The mysterious monster digests you.");
  45.             u.uhp = 0;
  46.         }
  47.         if(u.uhp < 1) done_in_by(mtmp);
  48.         return(0);
  49.     }
  50.     if(!index("&DuxynNF",mdat->mlet))
  51.         tmp = hitu(mtmp,d(mdat->damn,mdat->damd));
  52.     else
  53.         tmp = 0;
  54.  
  55.     ctmp = tmp && !mtmp->mcan &&
  56.       (!uarm || objects[uarm->otyp].a_can < rnd(3) || !rn2(50));
  57.     switch(mdat->mlet) {
  58.     case '&':
  59.         if(!mtmp->cham && !mtmp->mcan && !rn2(13)) {
  60.             (void) makemon(PM_DEMON,u.ux,u.uy);
  61.         } else {
  62.             (void) hitu(mtmp,d(2,6));
  63.             (void) hitu(mtmp,d(2,6));
  64.             (void) hitu(mtmp,rnd(3));
  65.             (void) hitu(mtmp,rnd(3));
  66.             (void) hitu(mtmp,rn1(4,2));
  67.         }
  68.         break;
  69.     case ',':
  70.         if(tmp) justswld(mtmp,"The trapper");
  71.         break;
  72.     case '\'':
  73.         if(tmp) justswld(mtmp,"The lurker above");
  74.         break;
  75.     case 'A':
  76.         if(ctmp && rn2(2)) {
  77.             pline("You feel weaker!");
  78.             losestr(1);
  79.         }
  80.         break;
  81.     case 'C':
  82.         (void) hitu(mtmp,rnd(6));
  83.         break;
  84.     case 'c':
  85.         if(!rn2(5)) {
  86.             pline("You hear %s's hissing!", monnam(mtmp));
  87.             if(ctmp || !rn2(5)) {
  88.                 pline("You get turned to stone!");
  89.                 done_in_by(mtmp);
  90.             }
  91.         }
  92.         break;
  93.     case 'D':
  94.         if(rn2(6) || mtmp->mcan) {
  95.             (void) hitu(mtmp,d(3,10));
  96.             (void) hitu(mtmp,rnd(8));
  97.             (void) hitu(mtmp,rnd(8));
  98.             break;
  99.         }
  100.         kludge("%s breathes fire!","The dragon");
  101.         buzz(-1,mtmp->mx,mtmp->my,u.ux-mtmp->mx,u.uy-mtmp->my);
  102.         break;
  103.     case 'd':
  104.         (void) hitu(mtmp,d(2,4));
  105.         break;
  106.     case 'e':
  107.         (void) hitu(mtmp,d(3,6));
  108.         break;
  109.     case 'F':
  110.         if(mtmp->mcan) break;
  111.         kludge("%s explodes!","The freezing sphere");
  112.         if(Cold_resistance) pline("You don't seem affected by it.");
  113.         else {
  114.             xchar dn;
  115.             if(17-(u.ulevel/2) > rnd(20)) {
  116.                 pline("You get blasted!");
  117.                 dn = 6;
  118.             } else {
  119.                 pline("You duck the blast...");
  120.                 dn = 3;
  121.             }
  122.             losehp_m(d(dn,6), mtmp);
  123.         }
  124.         mondead(mtmp);
  125.         return(1);
  126.     case 'g':
  127.         if(ctmp && multi >= 0 && !rn2(6)) {
  128.             kludge("You are frozen by %ss juices","the cube'");
  129.             nomul(-rnd(10));
  130.         }
  131.         break;
  132.     case 'h':
  133.         if(ctmp && multi >= 0 && !rn2(5)) {
  134.             nomul(-rnd(10));
  135.             kludge("You are put to sleep by %ss bite!",
  136.                 "the homunculus'");
  137.         }
  138.         break;
  139.     case 'j':
  140.         tmp = hitu(mtmp,rnd(3));
  141.         tmp &= hitu(mtmp,rnd(3));
  142.         if(tmp){
  143.             (void) hitu(mtmp,rnd(4));
  144.             (void) hitu(mtmp,rnd(4));
  145.         }
  146.         break;
  147.     case 'k':
  148.         if((hitu(mtmp,rnd(4)) || !rn2(3)) && ctmp){
  149.             poisoned("bee's sting",mdat->mname);
  150.         }
  151.         break;
  152.     case 'L':
  153.         if(tmp) stealgold(mtmp);
  154.         break;
  155.     case 'N':
  156.         if(mtmp->mcan && !Blind) {
  157.     pline("%s tries to seduce you, but you seem not interested.",
  158.             Amonnam(mtmp, "plain"));
  159.             if(rn2(3)) rloc(mtmp);
  160.         } else if(steal(mtmp)) {
  161.             rloc(mtmp);
  162.             mtmp->mflee = 1;
  163.         }
  164.         break;
  165.     case 'n':
  166.         if(!uwep && !uarm && !uarmh && !uarms && !uarmg) {
  167.             pline("%s hits! (I hope you don't mind)",
  168.             Monnam(mtmp));
  169.             u.uhp += rnd(7);
  170.             if(!rn2(7)) u.uhpmax++;
  171.             if(u.uhp > u.uhpmax) u.uhp = u.uhpmax;
  172.             flags.botl = 1;
  173.             if(!rn2(50)) rloc(mtmp);
  174.         } else {
  175.             (void) hitu(mtmp,d(2,6));
  176.             (void) hitu(mtmp,d(2,6));
  177.         }
  178.         break;
  179.     case 'o':
  180.         tmp = hitu(mtmp,rnd(6));
  181.         if(hitu(mtmp,rnd(6)) && ctmp &&
  182.             !u.ustuck && rn2(2)) {
  183.             u.ustuck = mtmp;
  184.             kludge("%s has grabbed you!","The owlbear");
  185.             u.uhp -= d(2,8);
  186.         } else if(u.ustuck == mtmp) {
  187.             u.uhp -= d(2,8);
  188.             pline("You are being crushed.");
  189.         }
  190.         break;
  191.     case 'P':
  192.         if(ctmp && !rn2(4))
  193.             justswld(mtmp,"The purple worm");
  194.         else
  195.             (void) hitu(mtmp,d(2,4));
  196.         break;
  197.     case 'Q':
  198.         (void) hitu(mtmp,rnd(2));
  199.         (void) hitu(mtmp,rnd(2));
  200.         break;
  201.     case 'R':
  202.         if(ctmp && uarmh && !uarmh->rustfree &&
  203.             (int) uarmh->spe >= -1) {
  204.             pline("Your helmet rusts!");
  205.             uarmh->spe--;
  206.         } else
  207.             if(ctmp && uarm && !uarm->rustfree &&
  208.              uarm->otyp < STUDDED_LEATHER_ARMOR &&
  209.              (int)uarm->spe >= -1) {
  210.                 pline("Your armor rusts!");
  211.                 uarm->spe--;
  212.             }
  213.         break;
  214.     case 'S':
  215.         if(ctmp && !rn2(8)) {
  216.             poisoned("snake's bite",mdat->mname);
  217.         }
  218.         break;
  219.     case 's':
  220.         if(tmp && !rn2(8)) {
  221.             poisoned("scorpion's sting",mdat->mname);
  222.         }
  223.         (void) hitu(mtmp,rnd(8));
  224.         (void) hitu(mtmp,rnd(8));
  225.         break;
  226.     case 'T':
  227.         (void) hitu(mtmp,rnd(6));
  228.         (void) hitu(mtmp,rnd(6));
  229.         break;
  230.     case 't':
  231.         if(!rn2(5)) rloc(mtmp);
  232.         break;
  233.     case 'u':
  234.         mtmp->mflee = 1;
  235.         break;
  236.     case 'U':
  237.         (void) hitu(mtmp,d(3,4));
  238.         (void) hitu(mtmp,d(3,4));
  239.         break;
  240.     case 'v':
  241.         if(ctmp && !u.ustuck) u.ustuck = mtmp;
  242.         break;
  243.     case 'V':
  244.         if(tmp) u.uhp -= 4;
  245.         if(ctmp && !rn2(3)) losexp();
  246.         break;
  247.     case 'W':
  248.         if(ctmp && !rn2(5)) losexp();
  249.         break;
  250. #ifndef NOWORM
  251.     case 'w':
  252.         if(tmp) wormhit(mtmp);
  253. #endif NOWORM
  254.         break;
  255.     case 'X':
  256.         (void) hitu(mtmp,rnd(5));
  257.         (void) hitu(mtmp,rnd(5));
  258.         (void) hitu(mtmp,rnd(5));
  259.         break;
  260.     case 'x':
  261.         { register long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
  262.           pline("%s pricks in your %s leg!",
  263.             Monnam(mtmp), (side == RIGHT_SIDE) ? "right" : "left");
  264.           Wounded_legs |= side + rnd(5);
  265.           losehp_m(2, mtmp);
  266.           break;
  267.         }
  268.     case 'y':
  269.         if(mtmp->mcan) break;
  270.         mondead(mtmp);
  271.         if(!Blind) {
  272.             pline("You are blinded by a blast of light!");
  273.             Blind = d(4,12);
  274.             seeoff(0);
  275.         }
  276.         return(1);
  277.     case 'Y':
  278.         (void) hitu(mtmp,rnd(6));
  279.         break;
  280.     }
  281.     if(u.uhp < 1) done_in_by(mtmp);
  282.     return(0);
  283. }
  284.